home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / emulator / uae-0.000 / uae-0 / uae-0.6.0 / macgui.c < prev    next >
C/C++ Source or Header  |  1996-05-23  |  5KB  |  242 lines

  1.  /* 
  2.   * UAE - The Un*x Amiga Emulator
  3.   * 
  4.   * Interface to the Tcl/Tk GUI
  5.   * 
  6.   * Copyright 1996 Bernd Schmidt
  7.   */
  8.  
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11. #include <string.h>
  12. #ifdef __unix
  13. #include <sys/types.h>
  14. #include <sys/stat.h>
  15. #include <sys/time.h>
  16. #endif
  17. #include <fcntl.h>
  18. #include <unistd.h>
  19. #include <signal.h>
  20. #include <SIOUX.h>
  21.  
  22. #include "config.h"
  23. #include "amiga.h"
  24. #include "options.h"
  25. #include "memory.h"
  26. #include "custom.h"
  27. #include "newcpu.h"
  28. #include "disk.h"
  29. #include "gui.h"
  30.  
  31. #define kAppleMenuID    128
  32. #define kFileMenuID        129
  33. #define    kEditMenuID        130
  34. #define    kDrivesMenuID    131
  35. #define    kMemoryMenuID    132
  36. #define    kResMenuID        135
  37. #define    kRateMenuID        134
  38. #define    kVideoMenuID    133
  39.  
  40. MenuHandle    resMenu,rateMenu;
  41. static int macLedState[5];
  42. int quit_program;
  43. extern int use_quickdraw;
  44. static Rect    powerRect, driveDf0Rect, driveDf1Rect, driveDf2Rect, driveDf3Rect;
  45.  
  46. static void sigchldhandler(int foo)
  47. {
  48. }
  49.  
  50. static void InitToolbox(void)
  51. {
  52.     InitGraf (&qd.thePort);
  53.     InitFonts ();
  54.     FlushEvents (everyEvent,0);
  55.     InitWindows ();
  56.     InitMenus ();
  57.     TEInit ();
  58.     InitDialogs (nil);
  59.     InitCursor ();
  60. }
  61.  
  62. #define kPrefStrRsrc 130
  63.  
  64. int gui_init(void)
  65. {    char pathString[1024];
  66.     Handle menuBar;
  67.     
  68.     InitToolbox();
  69.  
  70.     SIOUXSettings.initializeTB=false;
  71.     SIOUXSettings.standalone=false;
  72.     SIOUXSettings.setupmenus=false;
  73.     SIOUXSettings.autocloseonquit=true;
  74.     SIOUXSettings.asktosaveonclose=false;
  75.     SIOUXSettings.showstatusline=false;
  76.     SIOUXSettings.rows=11;
  77.     SIOUXSettings.toppixel=350;
  78.     SIOUXSettings.leftpixel=0;
  79.     fprintf(stderr,"Starting up the GUI╔\n");
  80.     SIOUXSetTitle("\pInfo Window");
  81.     
  82.     if (ReadPrefs(pathString))
  83.     {    if (*pathString != 0) add_filesys_unit("HD0", (char *)pathString, false);
  84.     }
  85.     else
  86.     {    if (*pathString == 0)
  87.         {    CreatePrefs();
  88.             WritePrefs(0);
  89.         }
  90.     }
  91.     
  92.     menuBar=GetNewMBar(128);
  93.     SetMenuBar(menuBar);
  94.     DisposeHandle(menuBar);
  95.     
  96.     AddResMenu(GetMenuHandle(kAppleMenuID), 'DRVR');
  97.  
  98.     if (screen_res != 4) DisableItem (GetMenuHandle(kFileMenuID), 3);
  99.     if (use_quickdraw) CheckItem(GetMenuHandle(kVideoMenuID),5,true);
  100.     if (use_gfxlib) CheckItem(GetMenuHandle(kVideoMenuID),7,true);
  101.     if (use_slow_mem) SetMenuItemText(GetMenuHandle(kMemoryMenuID), 1, "\pDisable 1 Mb (SlowMem)" );
  102.     if (!automount_uaedev) CheckItem(GetMenuHandle(kDrivesMenuID),7,true);
  103.     if (produce_sound) SetMenuItemText(GetMenuHandle(kFileMenuID), 9, "\pTurn Sound Off");
  104.     else SetMenuItemText(GetMenuHandle(kFileMenuID), 9, "\pTurn Sound On");
  105.     if (fake_joystick) SetMenuItemText(GetMenuHandle(kFileMenuID), 11, "\pTurn Joystick Off");
  106.     else SetMenuItemText(GetMenuHandle(kFileMenuID), 11, "\pTurn Joystick On");
  107.     
  108.     rateMenu=GetMenu(kRateMenuID);
  109.     InsertMenu(rateMenu, -1);
  110.     if (framerate == 1) CheckItem(rateMenu,1,true);
  111.     if (framerate == 3) CheckItem(rateMenu,2,true);
  112.     if (framerate == 5) CheckItem(rateMenu,3,true);
  113.     if (framerate == 7) CheckItem(rateMenu,4,true);
  114.     
  115.     resMenu=GetMenu(kResMenuID);
  116.     InsertMenu(resMenu, -1);
  117.     CheckItem(resMenu,(unsigned char)screen_res+1,true);
  118.     
  119.     DrawMenuBar();
  120.     
  121.     macLedState[0]=false;
  122.     macLedState[1]=false;
  123.     macLedState[2]=false;
  124.     macLedState[3]=false;
  125.     macLedState[4]=false;
  126.     
  127.     quit_program = 0;
  128. }
  129.  
  130. void gui_exit(void)
  131. {
  132.     DeleteMenu(kAppleMenuID);
  133.     DeleteMenu(kFileMenuID);
  134.     DeleteMenu(kEditMenuID);
  135.     DeleteMenu(kDrivesMenuID);
  136.     DeleteMenu(kMemoryMenuID);
  137.     DeleteMenu(kResMenuID);
  138.     DeleteMenu(kRateMenuID);
  139.     DeleteMenu(kVideoMenuID);
  140. }
  141.  
  142. void gui_prepare_leds(long screenV)
  143. {    
  144.     if (screen_res >= 3)
  145.     {    SetRect(&powerRect,70,(short)screenV+1,110,(short)screenV+11);
  146.         SetRect(&driveDf0Rect,220,(short)screenV+1,260,(short)screenV+11);
  147.         SetRect(&driveDf1Rect,292,(short)screenV+1,332,(short)screenV+11);
  148.         SetRect(&driveDf2Rect,365,(short)screenV+1,405,(short)screenV+11);
  149.         SetRect(&driveDf3Rect,436,(short)screenV+1,476,(short)screenV+11);
  150.     }
  151.     else
  152.     {    SetRect(&powerRect,46,(short)screenV+1,76,(short)screenV+11);
  153.         SetRect(&driveDf0Rect,106,(short)screenV+1,136,(short)screenV+11);
  154.         SetRect(&driveDf1Rect,166,(short)screenV+1,196,(short)screenV+11);
  155.         SetRect(&driveDf2Rect,226,(short)screenV+1,256,(short)screenV+11);
  156.         SetRect(&driveDf3Rect,286,(short)screenV+1,316,(short)screenV+11);
  157.     }
  158. }
  159.  
  160. void gui_update_leds(void)
  161. {    int i;
  162.  
  163.     for(i=0;i<=4;i++) gui_led(i,macLedState[i]);
  164. }
  165.  
  166. void gui_led(int led, int on)
  167. {    
  168.     macLedState[led]=on;
  169.     if (dont_want_aspect || screen_res == 2)
  170.     {    if (led == 0)
  171.         {    if (on)
  172.             {    ForeColor(redColor);
  173.                 PaintRect(&powerRect);
  174.             }
  175.             else
  176.             {    ForeColor(whiteColor);
  177.                 PaintRect(&powerRect);
  178.             }
  179.         }
  180.         else
  181.         {    switch (led)
  182.             {    case 1:
  183.                     if (on)
  184.                     {    ForeColor(greenColor);
  185.                         PaintRect(&driveDf0Rect);
  186.                     }
  187.                     else
  188.                     {    ForeColor(whiteColor);
  189.                         PaintRect(&driveDf0Rect);
  190.                     }
  191.                 break;
  192.                 
  193.                 case 2:
  194.                     if (on)
  195.                     {    ForeColor(greenColor);
  196.                         PaintRect(&driveDf1Rect);
  197.                     }
  198.                     else
  199.                     {    ForeColor(whiteColor);
  200.                         PaintRect(&driveDf1Rect);
  201.                     }
  202.                 break;
  203.                 
  204.                 case 3:
  205.                     if (on)
  206.                     {    ForeColor(greenColor);
  207.                         PaintRect(&driveDf2Rect);
  208.                     }
  209.                     else
  210.                     {    ForeColor(whiteColor);
  211.                         PaintRect(&driveDf2Rect);
  212.                     }
  213.                 break;
  214.                 
  215.                 case 4:
  216.                     if (on)
  217.                     {    ForeColor(greenColor);
  218.                         PaintRect(&driveDf3Rect);
  219.                     }
  220.                     else
  221.                     {    ForeColor(whiteColor);
  222.                         PaintRect(&driveDf3Rect);
  223.                     }
  224.                 break;
  225.             }
  226.         }
  227.     ForeColor(blackColor);
  228.     }
  229. }
  230.  
  231. void gui_filename(int num, char *name)
  232. {
  233. }
  234.  
  235. static void getline(char *p)
  236. {
  237. }
  238.  
  239. void gui_handle_events(void)
  240. {    
  241. }
  242.